Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Quality of Life improvements for World action and vocabulary space #330

Merged
merged 4 commits into from
Dec 9, 2022

Conversation

JackUrb
Copy link
Contributor

@JackUrb JackUrb commented Oct 4, 2022

Patch description
As surfaced in a meeting last week, it can be difficult to extract the vocabulary and action space of light. This PR introduces helpers that ease this flow:

  • World.get_vocab: Leverages get_vocab functions implemented through the OOGraph and GraphEvents to extract the available possible words that will appear in interacting with a given graph.
  • World.get_action_space: Leverages TEMPLATES introduced for all GraphEvent types to fill with nodes directly from the OOGraph. This covers all possible events that may occur in a given graph, not just ones possible from the current state, assuming the graph contents don't change.

It also adds templating for whisper and tell events, meaning these now show up in get_possible_actions calls by default. The free-form text portion of these is noted with <SOMETHING> and should be filled in.

Testing steps

from light.world.world import World
>>> from light.graph.structured_graph import OOGraph
>>> import json
>>> with open('scripts/examples/complex_world.json') as json_g:
...   json_graph = json_g.read()
... 
>>> g = OOGraph.from_json(json_graph)
>>> world = World({}, None)
>>> world.oo_graph = g
>>> voc = world.get_vocab()
>>> actions = world.get_action_space()
>>> len(voc)
1732
>>> len(actions)
19281
>>> import random
>>> random.sample(voc, 10)
['whether', 'growls', 'rob', 'important', 'life', 'plays', 'leadership', 'start', 'until', 'aura']
>>> random.sample(actions, 10)
['get huge cast iron pot from chair', 'put water pail in chamber pot', 'steal large earthenware jug of water for cooking and drinking from groundskeeper', 'give mug of mead to milk man', 'put torch in bathroom pot', 'give embalming equipment to master-at-arms', 'get pail from Unused chamber', 'put finest silk and velvet in cupboard', 'get spoon from Pine tree graveyard', 'get clothes made of various plant matter such as large leaves and vines from Empty storage room']

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 4, 2022
@xiangyu-peng
Copy link

Thanks.

@JackUrb JackUrb merged commit c2e5205 into main Dec 9, 2022
@JackUrb JackUrb deleted the gt-meet-improvements branch December 9, 2022 20:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants